

let timeId
export const test = {
  namespaced: true,
  state: {
    pageLoading: false,
    beforeMiniInfo: {},
  },
  getters: {
    getPageLoading(state) {
      return state.pageLoading
    },
  },
  mutations: {
    setPageLoading(state, loading) {
      state.pageLoading = loading
    },
  },
  actions: {
    async setPageLoadingAction({ commit }, loading) {
      if (loading) {
        clearTimeout(timeId)
        // 防止闪烁
        timeId = setTimeout(() => {
          commit('setPageLoading', loading)
        }, 50)
      } else {
        commit('setPageLoading', loading)
        clearTimeout(timeId)
      }
    },
  },
}
